//
//  LZTopicVoiceView.m
//  LZBS
//
//  Created by 郝庆 on 16/6/10.
//  Copyright © 2016年 haoqing. All rights reserved.
//
#import "LZTopicVoiceView.h"
#import "LZTopic.h"
#import <UIImageView+WebCache.h>
#import "LZSeeBigViewController.h"

@interface LZTopicVoiceView ()
@property (weak, nonatomic) IBOutlet UILabel *playCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *voiceTimeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@end

@implementation LZTopicVoiceView
- (void)awakeFromNib
{
    // 从xib中加载进来的控件的autoresizingMask默认是UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
    self.autoresizingMask = UIViewAutoresizingNone;
    self.imageView.userInteractionEnabled = YES;
    [self.imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(seeBig)]];
}

- (void)seeBig
{
    LZSeeBigViewController *seeBig = [[LZSeeBigViewController alloc] init];
    seeBig.topic = self.topic;
    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:seeBig animated:YES completion:nil];
}

- (void)setTopic:(LZTopic *)topic
{
    _topic = topic;
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:topic.large_image]];
    self.playCountLabel.text = [NSString stringWithFormat:@"%zd播放",topic.playcount];
    self.voiceTimeLabel.text = [NSString stringWithFormat:@"%02ld:%02ld",topic.voicetime / 60, topic.voicetime % 60];
}
@end
